package com.jeeni.tetrisproject;

import java.util.Random;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;

public class TetrisSound {
	
	private Sound[] sndSakura;
	private Sound[] sndPiano;
	private Sound[] sndSaw;
	
	private Music BGM;
	
	public final static String sndSakura1 = "sounds/Sakura_1.wav";
	public final static String sndSakura2 = "sounds/Sakura_2.wav";
	public final static String sndSakura3 = "sounds/Sakura_3.wav";
	
	public final static String sndPiano1 = "sounds/Piano_1.wav";
	public final static String sndPiano2 = "sounds/Piano_2.wav";
	public final static String sndPiano3 = "sounds/Piano_3.wav";
	public final static String sndPiano4 = "sounds/Piano_4.wav";
	public final static String sndPiano5 = "sounds/Piano_5.wav";
	public final static String sndPiano6 = "sounds/Piano_6.wav";
	
	public final static String sndSaw1 = "sounds/Saw_1.wav";
	public final static String sndSaw2 = "sounds/Saw_2.wav";
	public final static String sndSaw3 = "sounds/Saw_3.wav";
	
	public final static String bgm = "sounds/bgm.mp3";
	
	public TetrisSound()
	{
		BGM = Gdx.audio.newMusic(Gdx.files.internal(bgm));
		BGM.setLooping(true);
		BGM.play();
		
		sndSakura = new Sound[3];
		sndSakura[0] = Gdx.audio.newSound(Gdx.files.internal(sndSakura1));
		sndSakura[1] = Gdx.audio.newSound(Gdx.files.internal(sndSakura2));
		sndSakura[2] = Gdx.audio.newSound(Gdx.files.internal(sndSakura3));
		
		sndPiano = new Sound[6];
		sndPiano[0] = Gdx.audio.newSound(Gdx.files.internal(sndPiano1));
		sndPiano[1] = Gdx.audio.newSound(Gdx.files.internal(sndPiano2));
		sndPiano[2] = Gdx.audio.newSound(Gdx.files.internal(sndPiano3));
		sndPiano[3] = Gdx.audio.newSound(Gdx.files.internal(sndPiano4));
		sndPiano[4] = Gdx.audio.newSound(Gdx.files.internal(sndPiano5));
		sndPiano[5] = Gdx.audio.newSound(Gdx.files.internal(sndPiano6));
		
		sndSaw = new Sound[3];
		sndSaw[0] = Gdx.audio.newSound(Gdx.files.internal(sndSaw1));
		sndSaw[1] = Gdx.audio.newSound(Gdx.files.internal(sndSaw2));
		sndSaw[2] = Gdx.audio.newSound(Gdx.files.internal(sndSaw3));
	}
	
	public void playSakura()
	{
		Random rand = new Random();
		int no = rand.nextInt(3);
		float vol = rand.nextFloat();
		sndSakura[no].play(vol);
	}
	
	public void playPiano()
	{
		Random rand = new Random();
		int no = rand.nextInt(3);
		float vol = rand.nextFloat();
		sndPiano[no].play(vol);
	}
	
	public void playSaw()
	{
		Random rand = new Random();
		int no = rand.nextInt(3);
		float vol = rand.nextFloat();
		sndSaw[no].play(vol);
	}
}
